//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

namespace Microsoft.Research.DataLayer
{
    using System;
    using System.Collections.Generic;
    using System.ServiceModel;
    using Microsoft.Research.DataLayer.ServiceModel;

    /// <summary>
    /// Contract for silverlight service.
    /// </summary>
    [ServiceContract]
    public interface ITridentService
    {
        /// <summary>
        /// Gets the user role.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns></returns>
        [OperationContract(Name = "GetUserRole")]
        UserRole GetUserRole(UserModel user);

        /// <summary>
        /// Loads the user.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <returns></returns>
        [OperationContract(Name = "LoadUser")]
        UserModel LoadUser(string userName);

        /// <summary>
        /// Gets the workflow categories.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns></returns>
        [OperationContract(Name = "GetWorkflowCategories")]
        List<LeftPaneModel> GetWorkflowCategories(UserModel user);

        /// <summary>
        /// Gets all users my workflows.
        /// </summary>
        /// <param name="currentUser">The current user.</param>
        /// <returns></returns>
        [OperationContract(Name = "GetAllUsersMyWorkflows")]
        List<LeftPaneModel> GetAllUsersMyWorkflows(UserModel currentUser);

        /// <summary>
        /// Gets my workflows for user.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns></returns>
        [OperationContract(Name = "GetMyWorkflowsForUser")]
        List<LeftPaneModel> GetMyWorkflowsForUser(UserModel user);

        /// <summary>
        /// Gets all shared workflows for current user.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns></returns>
        [OperationContract(Name = "GetAllSharedWorkflowsForCurrentUser")]
        List<LeftPaneModel> GetAllSharedWorkflowsForCurrentUser(UserModel user);

        /// <summary>
        /// Gets the workflow by id.
        /// </summary>
        /// <param name="workflowId">The workflow id.</param>
        /// <returns></returns>
        [OperationContract(Name = "GetWorkflowById")]
        DetailedWorkflowModel GetWorkflowById(Guid workflowId);

        /// <summary>
        /// Gets the workflow required params.
        /// </summary>
        /// <param name="workflow">The workflow.</param>
        /// <returns></returns>
        [OperationContract(Name = "GetWorkflowRequiredParams")]
        List<ParameterDescriptionModel> GetWorkflowRequiredParams(WorkflowModel workflow);

        /// <summary>
        /// Gets the available nodes.
        /// </summary>
        /// <param name="isInteractive">if set to <c>true</c> [is interactive].</param>
        /// <returns></returns>
        [OperationContract(Name = "GetAvailableNodes")]
        List<NodeModel> GetAvailableNodes(bool isInteractive);

        /// <summary>
        /// Gets the outputs.
        /// </summary>
        /// <param name="jobID">The job ID.</param>
        /// <returns></returns>
        [OperationContract(Name = "GetOutputs")]
        List<DataProductModel> GetOutputs(Guid jobID);

        /// <summary>
        /// Gets the job details.
        /// </summary>
        /// <param name="jobID">The job ID.</param>
        /// <returns></returns>
        [OperationContract(Name = "GetJobDetails")]
        JobDetails GetJobDetails(Guid jobID);

        /// <summary>
        /// Terminates the job.
        /// </summary>
        /// <param name="jobID">The job ID.</param>
        /// <param name="user">The user.</param>
        [OperationContract(Name = "TerminateJob")]
        void TerminateJob(Guid jobID, UserModel user);

        /// <summary>
        /// Executes the workflow.
        /// </summary>
        /// <param name="jobDetails">The job details.</param>
        /// <param name="scheduledUser">The scheduled user.</param>
        /// <returns></returns>
        [OperationContract(Name = "ExecuteWorkflow")]
        JobDetails ExecuteWorkflow(JobDescriptionModel jobDetails, UserModel scheduledUser);

        /// <summary>
        /// Checks for activity.
        /// </summary>
        /// <param name="workflow">The workflow.</param>
        /// <param name="user">The user.</param>
        /// <returns></returns>
        [OperationContract(Name = "CheckForActivity")]
        bool CheckForActivity(WorkflowModel workflow, UserModel user);
    }
}
